package logic

import (
	"context"
	"user_svc/models/mysql"

	"user_svc/internal/svc"
	"user_svc/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type PositionAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPositionAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PositionAddLogic {
	return &PositionAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 职业发布
func (l *PositionAddLogic) PositionAdd(in *user.PositionAddRequest) (*user.PositionAddResponse, error) {
	// todo: add your logic here and delete this line

	position := mysql.Position{
		Name:    in.Name,
		Types:   in.Types,
		Address: in.Address,
		Price:   float64(in.Price),
		Desc:    in.Desc,
	}

	mysql.DB.Debug().Create(&position)

	return &user.PositionAddResponse{
		Id: int64(position.ID),
	}, nil
}
